<?php include("../../includes/includes.php"); ?>
<?php
connect($config);
$loggedInTeam = getLoggedInTeam();
$draftItems = getDraft($loggedInTeam->leagueId, true);
$currentPick = getCurrentPick($loggedInTeam->leagueId);

$lastRound = 0;
$result = "<table align='center' width='80%'>";
$result .= "<tr>";
$count = count($draftItems);
for ($i = 0; $i < $count; $i++) {
	if ($draftItems[$i]->round != $lastRound) {
		$result .= "<tr>";
		$result .= "<td colspan=3><br><br><b><font size='3'>Round " . $draftItems[$i]->round . "</font></b><br><br></td>";
		$result .= "</tr>";
		
		$lastRound = $draftItems[$i]->round;
	}
	
	$result .= "<tr>";
	
	if ($draftItems[$i]->pickNumber == $currentPick) {
		$result .= "<td width='5%'><b>#" . $draftItems[$i]->pickNumber . "</b></td>";
		$result .= "<td width='10%'><b>" . $draftItems[$i]->coachName . "</b></td>";
		$result .= "<td width='60'></td>";
	}
	else {
		$result .= "<td width='5%'>#" . $draftItems[$i]->pickNumber . "</td>";
		$result .= "<td width='10%'>" . $draftItems[$i]->coachName . "</td>";
		if ($draftItems[$i]->player != null) {
			$result .= "<td width='60%'>" . getPlayerDisplayForPlayer($draftItems[$i]->player) . "</td>";
		}
	}
	
	$result .= "</tr>";
}

$result .= "</table>";
mysql_close();
?>

<script>
parent.document.getElementById("draftDiv").innerHTML = "<?echo $result?>";
</script>
